package com.demo.modules.dto;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * 自定义的认证
 * 只需要使用编码即可进行认证
 *
 * @author molong
 * @since 2024/5/24
 */
public class CustomAuthenticationToken extends AbstractAuthenticationToken {
    private final String authCode;

    public CustomAuthenticationToken(String authCode) {
        super(null);
        this.authCode = authCode;
    }

    @Override
    public Object getCredentials() {
        //没有密码，通过用户名登录
        return null;
    }

    @Override
    public Object getPrincipal() {
        return authCode;
    }
}
